package sparrow.common;

import java.util.LinkedList;
import java.util.Iterator;

public class Topic {

	private LinkedList<ChatMessage> messageList;
	private String label;
	private int color;

	public Topic(String label, int color) {
		this.label = label;
		this.color = color;
		this.messageList = new LinkedList<ChatMessage>();
	}
	
	
	public void addMessage(ChatMessage msg) {
		msg.setParent(this);
		messageList.add(msg);
		
	}
	
	public void removeMessage(ChatMessage msg) {
		msg.setParent(null);
		messageList.remove(msg);
	}
	

	public void setLabel(String label) {
		this.label = label;
	}

	public void setColor(int color) {
		this.color = color;
	}

	public String label() {
		return label;
	}

	public int color() {
		return color;
	}

	public LinkedList<ChatMessage> getMsgs() {
		return messageList;
	}

	public String toString() {
		String result = "";
		for (ChatMessage msg : messageList) {
			result = result + msg + "\n";
		}
		return result;
	}

}
